package cn.well.cloud.quartz.core.config;

import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import cn.well.cloud.quartz.core.task.TaskSchedulerFactory;

/**
 * 
 * wison
 * 下午9:57:20
 */
@Configuration
public class QuartzConfig {
    @Autowired
    private TaskSchedulerFactory taskSchedulerFactory;
    
    @Bean
    public TaskSchedulerFactory jobFactory(){
        return new TaskSchedulerFactory();
    }
    
    @Bean
    public SchedulerFactoryBean schedulerFactoryBean() {
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setJobFactory(taskSchedulerFactory);
        return schedulerFactoryBean;
    }
 
    @Bean
    public Scheduler scheduler() {
        return schedulerFactoryBean().getScheduler();
    }
}

